$().ready(function() {

	$("#bookId").val($("#bookIdNmae").val());
	$("#post").val($("#postHidden").val());
	$("#invoiceType").val($("#invoiceTypeHidden").val());
	validateRule();
});

$.validator.setDefaults({
	submitHandler : function() {
		update();
	}
});
function update() {

	$.ajax({
		cache : true,
		type : "POST",
		url : "/jzweb/bookOrder/update",
		data : $('#signupForm').serialize(),// 你的formid
		async : false,
		error : function(request) {
			parent.layer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {
				parent.layer.msg("操作成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				parent.layer.alert(data.msg)
			}

		}
	});

}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
			bookId : {
				required : true
			},
			orderNumber : {
				required : true
			},
			orderPrimary : {
				required : true
			},
			orderIntermediate : {
				required : true
			},
			discount : {
				required : true
			},
			province : {
				required : true
			},
			address : {
				required : true
			},
			school : {
				required : true
			},
			addressee : {
				required : true
			},
			billingNumber : {
				required : true
			}

		},
		messages : {
			bookId : {
				required : icon + "请选择对应书籍种类"
			},
			orderNumber : {
				required : icon + "请输入理论订单数量"
			},
			orderPrimary : {
				required : icon + "请输入理论初级数量"
			},
			orderIntermediate : {
				required : icon + "请输入理论中级数量"
			},
			discount : {
				required : icon + "请输入折扣价"
			},
			province : {
				required : icon + "请输入省份"
			},
			address : {
				required : icon + "请输入详细地址"
			},
			school : {
				required : icon + "请输入单位名称或学校名称"
			},
			addressee : {
				required : icon + "请输入收件人"
			},
			billingNumber : {
				required : icon + "请输入纳税识别号"
			}
		}
	})
}